home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / ASMFAQ.ZIP / ASM_FAQ6.TXT < prev    next >
Encoding:
Internet Message Format  |  1996-04-03  |  14.3 KB

  1. From news.primenet.com!nntp.news.primenet.com!news.sprintlink.net!gryphon.phoenix.net!academ!binky.capnet.state.tx.us!goblin.tdh.state.tx.us!geraldo.cc.utexas.edu!cs.utexas.edu!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!sgigate.sgi.com!news1.best.com!news.aimnet.com!ns2.mainstreet.net!sloth.swcp.com!news.dgsys.com!DGS.dgsys.com!raymoon Tue Apr  2 15:45:00 1996
  2. Path: news.primenet.com!nntp.news.primenet.com!news.sprintlink.net!gryphon.phoenix.net!academ!binky.capnet.state.tx.us!goblin.tdh.state.tx.us!geraldo.cc.utexas.edu!cs.utexas.edu!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!sgigate.sgi.com!news1.best.com!news.aimnet.com!ns2.mainstreet.net!sloth.swcp.com!news.dgsys.com!DGS.dgsys.com!raymoon
  3. From: raymoon@dgsys.com (Raymond Moon)
  4. Newsgroups: alt.lang.asm,comp.lang.asm.x86,news.answers,alt.answers,comp.answers
  5. Subject: x86 Assembly Language FAQ - Borland TASM
  6. Supersedes: <4gdsot$o9c@news.dgsys.com>
  7. Followup-To: alt.lang.asm,comp.lang.asm.x86
  8. Date: 21 Mar 1996 22:51:53 GMT
  9. Organization: MoonWare
  10. Lines: 340
  11. Approved: news-answers-request@MIT.EDU
  12. Distribution: world
  13. Expires: Sat, 20 Apr 1996 23:59:59 GMT
  14. Message-ID: <4ismi9$2tq@news.dgsys.com>
  15. Reply-To: raymoon@moonware.dgsys.com
  16. NNTP-Posting-Host: dgs.dgsys.com
  17. Summary: This is the FAQ for the x86 Assembly Language programmers for the
  18.  alt.lang.asm and comp.lang.asm.x86 newsgroups.  This particular section of
  19.  the FAQ contains x86 assembly information specific to the Borland TASM
  20.  assembler.
  21. Keywords: x86 Assemby Language ASM FAQ Borland TASM
  22. X-Newsreader: TIN [version 1.2 PL2]
  23. Xref: news.primenet.com alt.lang.asm:8424 comp.lang.asm.x86:18601 news.answers:66834 alt.answers:16276 comp.answers:17533
  24.  
  25. Archive-name: assembly-language/x86/borland
  26. Posting-Frequency: monthly (21st of every month)
  27. Last-modified: 1996/02/19
  28.  
  29. ------------------------------
  30.  
  31. Subject: 1. Introduction and Intent
  32.  
  33. This is the x86 Assembly Language FAQ for the comp.lang.asm.x86 and
  34. alt.lang.asm newsgroups.  This FAQ is posted monthly on or about the 21st
  35. of the month on both newsgroups and news.answers, alt.answers and
  36. comp.answers.  It also is archived at the normal FAQ archival sites and the
  37. SimTel mirror sites in the msdos/info directory.  Lastly, the current
  38. version is available from my web page as:
  39.    http://www2.dgsys.com/~raymoon/faq/asmfaq.zip
  40. Currently, this FAQ is broken into six sections.  The following are the
  41. section filenames and the scope of each section of the FAQ.
  42.  
  43. assembly-language/x86/general/part1 - This is the basic portion of the FAQ
  44.    that contains information of interest to all assembly language
  45.    programmers.  In general, the information contained in this portion of
  46.    the FAQ is not specific to any particular assembler.
  47.  
  48. assembly-language/x86/general/part2 - This is a continuation of the above
  49.    FAQ.
  50.  
  51. assembly-language/x86/general/part3 - This is a continuation of the above
  52.    FAQ.
  53.  
  54. assembly-language/x86/microsoft - This portion of the FAQ contains
  55.    information specific for the Microsoft MASM.
  56.  
  57. assembly-language/x86/borland - This portion of the FAQ contains
  58.    information specific for the Borland TASM.
  59.  
  60. assembly-language/x86/a86 - This portion of the FAQ contains information
  61.    specific for the Shareware A86 Assembler and D86 Debugger.
  62.  
  63. The scope and content of this FAQ is to go beyond just answering the
  64. frequently asked questions.  I am including pointers to assembly language
  65. treasure troves that are hidden out on the internet.  I believe that this
  66. will enhance the FAQ's value not only to the novices but also to the old
  67. hands.
  68.  
  69. Any subject listed as "OPEN" means that this topic as been requested but no
  70. one has come forth and volunteered to write this section.  Volunteers
  71. please indicate your intentions to the author listed below either by
  72. posting to either newsgroup or by sending e-mail to the author at the below
  73. address.
  74.  
  75. The general guidelines for submission are:
  76.  * accuracy and conciseness;
  77.  * pointers to where on the internet more detailed information is
  78.    available; and
  79.  * any code submitted will be generic so that most assemblers can assemble
  80.    successfully.
  81.  
  82. Any subject listed as "UNDER CONSTRUCTION" has a volunteer currently
  83. writing that subject.  If you desire to assist or have some information
  84. that you believe would be of help in writing that particular subject,
  85. contact the contributor of that subject or post to both newsgroups.  Once a
  86. subject is submitted to me, I will post it on both newsgroups for comment. 
  87. After any changes that may be necessary are made, I will include it in the
  88. next posting of the FAQ.
  89.  
  90. For the ease of determining what has changed since the last FAQ, the Table
  91. of Contents will have "REVISED" at the end of the subject line for all
  92. revised subjects.  If more than one FAQ revision has been missed, the "Last
  93. Changed:" entry at the end of each subject can be used to determine which
  94. subjects have been revised during the intervening time frame.
  95.  
  96. The information in this FAQ is free for all to use as long as you
  97. acknowledge the source.  This FAQ can be reproduced in part or in its
  98. entirety as long as the copyright is included.  This FAQ can be made
  99. available on public servers, like ftp, gopher or WWW servers.  Please do
  100. not modify the file, such as converting it into some other format, without
  101. prior permission of the author.
  102.  
  103. All references to files and locations are in Uniform Resource Locators
  104. (URLs) format.  Some web browser will be able to use these URLs directly as
  105. hot links.  If the format is not clear to you, get RFC 1738.  It is
  106. available from:   ftp://is.internic.net/rfc/rfc1738.txt 
  107.  
  108. Suggestions for changes and comments are always welcome.  They can be
  109. posted to either newsgroup or e-mailed directly to the me.
  110.  
  111. Author: Raymond Moon, raymoon@moonware.dgsys.com
  112. Copyright 1996 - Raymond Moon
  113. ALL RIGHTS RESERVED
  114. Last Changed: 17 Feb 96
  115.  
  116. ------------------------------
  117.  
  118. Subject: 2. Table of Contents
  119.  
  120. 1. Introduction And Intent
  121. 2. Table Of Contents
  122. 3. TASM Ideal Mode
  123. 4. Borland TASM Information
  124. 5. Borland tools/Windows 95 Interworking Patches Available
  125. 6. Borland TASM List Server
  126.  
  127. ------------------------------   
  128.  
  129. Subject: 3. TASM Ideal Mode
  130.  
  131. 3.1  SUMMARY
  132.  
  133. TASM, Borland's assembler, supports an alternative to MASM emulation.  This
  134. is known as Ideal mode and provides several advantages over MASM.  The key
  135. (questionable) disadvantage, of course, is that MASM style assemblers
  136. cannot assemble Ideal mode programs.
  137.  
  138. 3.2  MEMORY CONTENTS
  139.  
  140. Square brackets are used consistently to refer to memory contents.  Notice
  141. that size qualifiers are not necessary when TASM has enough information by
  142. context to figure out the data size involved.  Here are some examples
  143. without segment details:
  144.  
  145.    ByteVal db ?       ; "ByteVal" is name of byte variable
  146.  
  147.    mov ax, bx         ; OK:  Move value of BX to AX
  148.  
  149.    mov ax, [bx]       ; OK:  Move word at address BX to AX.  Size of
  150.                          ; destination is used to generate proper object
  151.                          ; code
  152.  
  153.    mov ax, [word bx]  ; OK:  Same as above with unnecessary size
  154.                          ; qualifier
  155.  
  156.    mov ax, [word ptr bx]
  157.                          ; OK:  Same as above with unnecessary size
  158.                          ; qualifier and redundant pointer prefix
  159.  
  160.    mov al, [bx]       ; OK:  Move byte at address BX to AL.  Size of
  161.                          ; destination is used to generate proper object
  162.                          ; code
  163.  
  164.    mov [bx], al       ; OK:  Move AL to location BX
  165.  
  166.    mov ByteVal, al    ; Warning: "ByteVal" needs brackets
  167.  
  168.    mov [ByteVal], al  ; OK:  Move AL to memory location named "ByteVal"
  169.  
  170.    mov [ByteVal], ax  ; Error: unmatched operands
  171.  
  172.    mov al, [bx + 2]   ; OK:  Move byte from memory location BX + 2 to
  173.                          ; AL
  174.  
  175.    mov al, bx[2]      ; Error: indexes must occur with "+" as above
  176.  
  177.    mov bx, Offset ByteVal
  178.                          ; OK: Offset statement does not use brackets
  179.  
  180.    mov bx, Offset [ByteVal]
  181.                          ; Error:  offset cannot be taken of the contents
  182.                          ; of memory
  183.  
  184.    lea bx, [ByteVal]  ; OK:  Load effective address of "ByteVal"
  185.  
  186.    lea bx, ByteVal    ; Error:  brackets required
  187.  
  188.    mov ax, 01234h     ; OK:  Move constant word to AX
  189.  
  190.    mov [bx], 012h     ; Warning: size qualifier needed to determine
  191.                          ; whether to populate byte or word
  192.  
  193.    mov [byte bx], 012h
  194.                          ; OK:  constant 012h is moved to byte at address
  195.                          ; BX
  196.  
  197.    mov [word bx], 012h
  198.                          ; OK:  constant 012h is moved to word at address
  199.                          ; BX
  200.  
  201. STRUCTURE REFERENCES
  202.  
  203. Ideal mode handles structured records beautifully.  When referring to
  204. structure members the dot operator is used.  The name to the left of the
  205. dot is always the address of a structure and the name to right is always a
  206. structure member.  Ideal mode permits member names to be duplicated in
  207. different structures.  Here is a simple example, again without segment
  208. details:
  209.  
  210.    Struc PosType
  211.        Row    dw  ?
  212.        Col    dw  ?
  213.    Ends PosType
  214.  
  215.    Union PosValType
  216.        Pos PosType    ?
  217.        Val dd         ?
  218.    Ends PosValType
  219.  
  220.    Point   PosValType ?
  221.  
  222.    mov [Point.Pos.Row], bx   ; OK:  Move BX to Row component of Point
  223.  
  224.    mov [Point.Pos.Row], bl   ; Error:  mismatched operands
  225.  
  226. INDIRECTION
  227.  
  228. Ideal mode enforces type-size checking even with indirected references. 
  229. Using the above structure, here is how indirection is handled.  BX is
  230. assumed to point to an instance of PosValType in memory.  Indirection is
  231. used frequently when pointers are passed to procedures.
  232.  
  233.    mov [(PosValType bx).Pos.Row], ax
  234.                       ; OK: Move AX to Row component of PosValType instance
  235.                       ; pointed to by BX
  236.  
  237.    mov [bx + PosValType.Pos.Row], ax
  238.                       ; OK: same as above
  239.  
  240.    mov [bx + PosValType.Pos.Row], al
  241.                       ; Error:  mismatched operands
  242.  
  243. SEGMENT GROUPS
  244.  
  245. The Offset operator always evaluates the offset of a data instance relative
  246. to its group, not its segment.  This allows Offset to be used without
  247. qualifying each reference with the appropriate group name.  Labels in a
  248. segment could be used to determine segment offsets if needed.
  249.  
  250. RESOURCES
  251.  
  252. Books and files which will be of interest to programmers wishing to know
  253. more about the Ideal mode of Borland's TASM assembler include the
  254. following:
  255.  
  256.    Turbo Assembler User's Guide / Borland International.
  257.    ------------------------------------------------------------------
  258.    Naturally, this is the definitive text on Ideal mode.  Its focus is
  259.    strictly on using TASM; it does not cover assembly language or the x86
  260.    instruction set.  Exasperatingly, the examples in the book all use MASM
  261.    emulation mode, and only one of the four complete program examples
  262.    included with TASM (at least version 3.1) uses Ideal mode.  The example
  263.    that does use Ideal mode is a very flexible WHEREIS program.  Studying
  264.    this 13 file example should be sufficient for anyone wishing to
  265.    understand Ideal mode.
  266.  
  267.    Mastering Turbo Assembler / Tom Swan.
  268.    Indianapolis, IN:  Hayden Books, c 1989.
  269.    -----------------------------------------------------------------------
  270.    This book is not just another Microsoft Assembler book reprinted with a
  271.    Turbo Assembler cover.  Swan uses and promotes Ideal mode throughout. 
  272.    This is a great beginning text for programmers who are still hassling
  273.    with the ubiquitous non-reentrant interrupt handler known as DOS.  It
  274.    includes an overview of the x86 instruction set.
  275.  
  276.    SKEL32.ZIP / Bill Magaletta.
  277.    Obtainable by ftp at hobbes.nmsu.edu:/os2/32bit/program as well as
  278.    ftp-os2.cdrom.com and CompuServe
  279.    -----------------------------------------------------------------------
  280.    This is a standalone 32 bit OS/2 Ideal mode program, the simplicity of
  281.    which will make converts of DOS programmers dealing with interrupts and
  282.    segments.  It includes an overview of the initial register states of
  283.    DOS and OS/2 programs.  This example illustrates the fact that TASM for
  284.    DOS can be used to produce object files for OS/2.
  285.  
  286. Contributor: Kurt Jung, kwjung@vela.acs.oakland.edu
  287. Last changed: 17 Jan 95
  288.  
  289. ------------------------------   
  290.  
  291. Subject: 4. Borland TASM Information
  292.  
  293. 4.1 Borland FTP Site
  294.  
  295. Borland maintains a ftp site which has a directory dedicated to TASM.  Most
  296. entries are patches and HOW-TOs, but there is a shell for TSRs that will
  297. load and unload either high or low.
  298.  
  299.    ftp://ftp.borland.com/pub/techinfo/techdocs/language/tools/turboasm
  300.  
  301. 4.2 Borland Web Site
  302.  
  303. At Borland's Web Site, I only could find product and ordering information
  304. on TASM.  The only reference to technical information was a pointer to
  305. Borland's ftp site.
  306.  
  307. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  308. Last changed: 11 Nov 95
  309.  
  310. ------------------------------   
  311.  
  312. Subject: 5. Borland tools/Windows 95 Interworking Patches Available
  313.  
  314. 5.1 TASM32/H2ASM/H2ASM32 FAIL UNDER WINDOWS95
  315.  
  316. Using the 32bit tools from Borland C++ 4.5 / TASM 4.0 under Windows 95 can
  317. fail when the DOS based tools tools are called from the Windows IDE.
  318.  
  319. The nature of the problem is that any attempt to specify a commands file
  320. using the @ style argument will fail due to an incompatability between
  321. Windows 95 long filenames, and the TASM32.EXE file-open code.
  322.  
  323. Note that by default the Borland C++ 4.5 IDE uses the @ directive for
  324. launching TASM32.EXE if 32bit instructions (which are not handled by the
  325. inline C++ assembler) are encountered in a user's source.
  326.  
  327. Although the Borland tools reportedly use the PowerPack DPMI extensions for
  328. their 32bit operation, user applications which use the Powerpack libraries
  329. do not seem to be affected by this problem.
  330.  
  331. A patch is available to correct this issue from location:
  332. ftp://ftp.borland.com/pub/techinfo/techdocs/language/tools/turboasm/ta4p01.zip
  333.  
  334. This should be applied using the patcher executable from location:
  335. ftp://ftp.borland.com/pub/techinfo/techdocs/language/cpp/bcpp/patch/patch.zip
  336.  
  337. Contributor: Iain Barker, ibarker@bnr.ca
  338. Last changed: 19 Feb 96
  339.  
  340. ------------------------------   
  341.  
  342. Subject: 6. Borland TASM List Server
  343.  
  344. 6.1 DESCRIPTION
  345.  
  346. There is a list server available that is devoted to Borland's TASM
  347. Assembler.
  348.  
  349. 6.2 JOINING
  350.  
  351. To join send e-mail to:
  352.    listserv%brufpb.bitnet@listserv.net 
  353. with the phrase 
  354.    subscribe TASM-L your name
  355. in the text.
  356.  
  357. 6.3 SENDING E-MAIL TO ALL MEMBERS
  358.  
  359. To send e-mail to all members, send the e-mail to:
  360.    tasm-l%brufpb.bitnet@listserv.net
  361.  
  362. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  363. Last changed: 17 Feb 96
  364.  
  365.  
  366.